package cn.snmp.mutual.org.opennms.protocols.snmp;

import java.io.*;

import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnDecodingException;
import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnEncoder;
import cn.snmp.mutual.org.opennms.protocols.snmp.asn1.AsnEncodingException;


public abstract class SnmpV2Error implements SnmpSyntax, Cloneable, Serializable {
    static final long serialVersionUID = 5701182495454482383L;

    public SnmpV2Error() {
    }

    public SnmpV2Error(final SnmpV2Error second) {
    }

    public abstract byte typeId();

    public int encodeASN(final byte[] buf, final int offset, final AsnEncoder encoder) throws AsnEncodingException {
        return encoder.buildHeader(buf, offset, this.typeId(), 0);
    }

    public int decodeASN(final byte[] buf, final int offset, final AsnEncoder encoder) throws AsnDecodingException {
        final Object[] rVals = encoder.parseHeader(buf, offset);
        if ((byte) rVals[1] != this.typeId()) {
            throw new AsnDecodingException("Invalid ASN.1 type");
        }
        if ((int) rVals[2] != 0) {
            throw new AsnDecodingException("Invalid ASN.1 length");
        }
        return (int) rVals[0];
    }

    public abstract SnmpSyntax duplicate();

    public abstract Object clone();
}
